package resources.dao;

import java.util.ArrayList;

import javax.faces.model.SelectItem;

public class UtilDAO extends DatabaseDAO{
	public static ArrayList<SelectItem> getSelectItem(String name){
		ArrayList<SelectItem> temp = new ArrayList<SelectItem>();
		String sql = "call sp_hr_select(?)";
		try {
			getDBPoolConnection();
			conn.setAutoCommit(false);
			cs = conn.prepareCall(sql);
			cs.setString(1,name);
			rs = cs.executeQuery();
			conn.commit();
			while(rs.next()){
				temp.add(new SelectItem(rs.getString("t.id"),rs.getString("t.name")));
			}
		} catch (Exception e) {
			try {
				conn.rollback();
			} catch (Exception ex) {
				ex.printStackTrace();
			}
			e.printStackTrace();
			return null;
		} finally{
			closeConnection();
		}
		return temp;
	}
}
